Skip to content

Pass additional args to callable option cors_allowed_origins#398

Merged
miguelgrinberg merged 2 commits intomiguelgrinberg:mainfrom
wft-swas:patch-1
Apr 12, 2025
Merged

Pass additional args to callable option cors_allowed_origins#398
miguelgrinberg merged 2 commits intomiguelgrinberg:mainfrom
wft-swas:patch-1

Conversation

@wft-swas
Copy link
Copy Markdown
Contributor

@wft-swas wft-swas commented Apr 4, 2025

If option cors_allowed_origins is callable, pass additional args for default_origins and environ to it. Use try-except to still allow usage of a callback without these additional args.

Background:
For our project, we need to dynamically check for origins, which are allowed additionally to the default ones (especially the same origin).

The try-except is just a proposal to avoid a breaking change.

wft-swas and others added 2 commits April 4, 2025 13:25
If option cors_allowed_origins is callable, pass additional args for default_origins and environ to it.
Use try-except to still allow usage of a callback without these additional args.
@miguelgrinberg
Copy link
Copy Markdown
Owner

Thanks! I have simplified the CORS allowed hosts calculation a bit and changed your proposal call signature to include only origin and environ.

@miguelgrinberg miguelgrinberg merged commit 5cb5611 into miguelgrinberg:main Apr 12, 2025
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants